package com.example.hzq.food.model;

import com.example.hzq.food.bean.Success;
import com.example.hzq.food.bean.CollectBean;
import com.example.hzq.food.bean.FoodBean;
import com.example.hzq.food.bean.LoginBean;
import com.example.hzq.food.bean.MyBean;
import com.example.hzq.food.bean.OrderBean;
import com.example.hzq.food.bean.RegisterBean;
import com.example.hzq.food.bean.ShopBean;
import com.example.hzq.food.iface.iface;
import com.example.hzq.food.service.Service;

import java.util.List;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by hzq on 2017/6/13.
 */

public class Model implements iface {
    private Retrofit retrofit;
    private String BASEURL="http://60.205.189.39/";
    public Model(){
        retrofit=new Retrofit.Builder().baseUrl(BASEURL).addConverterFactory(GsonConverterFactory.create()).addConverterFactory(ScalarsConverterFactory.create()).build();
    }

    @Override
    public Call<List<FoodBean>> getfood(int shop_id) {
       Service service=retrofit.create(Service.class);
        return service.getfood(shop_id);
    }

    @Override
    public Call<LoginBean> login(String userName, String userPwd) {
       Service service=retrofit.create(Service.class);
        return service.login(userName,userPwd);
    }

    @Override
    public Call<RegisterBean> register(String userName, String userPwd, String phone, String address, String comment) {
        Service service=retrofit.create(Service.class);
        return service.register(userName,userPwd,phone,address,comment);
    }

    @Override
    public Call<List<ShopBean>> getshop() {
        Service service=retrofit.create(Service.class);
        return service.getshop();
    }

    @Override
    public Call<MyBean> getmy(int userid) {
        Service service=retrofit.create(Service.class);
        return service.getmy(userid);
    }

    @Override
    public Call<CollectBean> collectornoshop(int user_id, int shop_id) {
        Service service=retrofit.create(Service.class);
        return service.collectornoshop(user_id,shop_id);
    }

    @Override
    public Call<CollectBean> collectornofood(int user_id, int foodid) {
        Service service=retrofit.create(Service.class);
        return service.collectornofood(user_id,foodid);
    }

    @Override
    public Call<CollectBean> iscollect(int user_id, int shop_food_id, int flag) {
        Service service=retrofit.create(Service.class);
        return service.iscollect(user_id,shop_food_id,flag);
    }
    @Override
    public Call<List<OrderBean>> getallorder(int food_id) {
        Service service=retrofit.create(Service.class);
        return service.getallorder(food_id);
    }

    @Override
    public Call<Success> insertOrder(int user_id, int food, int num, double sum, String suggesttime) {
        Service service=retrofit.create(Service.class);
        return service.insertOrder(user_id,food,num,sum,suggesttime);
    }

    @Override
    public Call<Success> updata(int userid, String userName, String userPwd, String phone, String address) {
        Service service=retrofit.create(Service.class);
        return service.updata(userid,userName,userPwd,phone,address);
    }

    @Override
    public Call<List<FoodBean>> getfoodbysearch(String search) {
        Service service=retrofit.create(Service.class);
        return service.getfoodbysearch(search);
    }

    @Override
    public Call<Success> insertComment(int order_id, String content) {
        Service service=retrofit.create(Service.class);
        return service.insertComment(order_id,content);
    }

    @Override
    public Call<Success> updateComment(int order_id, String content) {
        Service service=retrofit.create(Service.class);
        return service.updateComment(order_id,content);
    }

    @Override
    public Call<Success> deleteComment(int order_id) {
        Service service=retrofit.create(Service.class);
        return service.deleteComment(order_id);
    }

    @Override
    public Call<List<OrderBean>> getalluserfoodorder(int food_id) {
        Service service=retrofit.create(Service.class);
        return service.getalluserfoodorder(food_id);
    }

    @Override
    public Call<FoodBean> getfoodbyid(int food_id) {
        Service service=retrofit.create(Service.class);
        return service.getfoodbyid(food_id);
    }

    @Override
    public Call<List<OrderBean>> getorder(int user_id) {
        Service service=retrofit.create(Service.class);
        return service.getorder(user_id);
    }

    @Override
    public Call<List<CollectBean>> getmycollect(int user_id, int flag) {
       Service service=retrofit.create(Service.class);
        return service.getmycollect(user_id,flag);
    }
}
